home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’92 / NetWarmer / source / Windowing.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-11  |  2.9 KB  |  126 lines  |  [TEXT/KAHL]

  1. /* © 1988, Bowers Development Corp. */
  2. /* Windowing.c */
  3.  
  4. #include "Globals.h"
  5. #include "Scrolling.h"
  6. #include "Miscellany.h"
  7. #include "FileM.h"
  8. #include "Dispatcher.h"
  9.  
  10. #include "Windowing.h"
  11.  
  12. /*----------*/
  13. void DoContent    (whichWindow)
  14. WindowPtr        whichWindow;
  15. {
  16.     Point            where;
  17.     ControlHandle    whichControl;
  18.     short            partCode;
  19.     Boolean            extendSel;
  20.  
  21.     if (whichWindow != FrontWindow ()) {
  22.         SelectWindow (whichWindow);
  23.     } else {
  24.         where = curEvent.where;
  25.         GlobalToLocal (&where);
  26.     
  27.         partCode = FindControl (where, whichWindow, &whichControl);
  28.     
  29.         if (whichControl == nil) {
  30.             extendSel = ((curEvent.modifiers & shiftKey) != 0);
  31.             if ((cur->text != nil)
  32.              && PtInRect (where, &((**(cur->text)).viewRect))) {
  33.                 TEClick (where, extendSel, cur->text);
  34.             } else {
  35.                 MouseInContent (where, curEvent.modifiers);
  36.             }
  37.         } else {
  38.             if ((whichControl == cur->vScroll)
  39.             ||  (whichControl == cur->hScroll)) {
  40.                 TrackScroll (whichControl, partCode, where, (ProcPtr) &ScrollWindow);
  41.             } else {
  42.                 DoControl (whichControl, partCode, where);
  43.             }
  44.         }    
  45.      }
  46. } /*DoContent*/
  47.  
  48. /*----------*/
  49. void DoDrag        (whichWindow)
  50. WindowPtr        whichWindow;
  51. {
  52.     Rect            limitRect;
  53.  
  54.      limitRect = (**(GetGrayRgn ())).rgnBBox;
  55.     DragWindow (whichWindow, curEvent.where, &limitRect);
  56. } /*DoDrag*/
  57.  
  58. /*----------*/
  59. void InvalGrowBox    (WindowPtr        whichWindow);
  60. void InvalGrowBox    (whichWindow)
  61. WindowPtr        whichWindow;
  62. {
  63.     Rect            growBox;
  64.     
  65.     #define port    whichWindow->portRect
  66.     SetRect (&growBox, port.right - 15, port.bottom - 15,
  67.                        port.right,        port.bottom);
  68.     InvalRect (&growBox);
  69.     #undef port
  70. } /*InvalGrowBox*/
  71.  
  72. /*----------*/
  73. void DoGrow        (whichWindow)
  74. WindowPtr        whichWindow;
  75. {
  76.     #define minWidth       55                                 
  77.     #define minHeight      55                                
  78.     #define maxint      32767                                
  79.  
  80.     short            maxWidth;
  81.     short            maxHeight;
  82.     Rect            sizeRect;
  83.     long            newSize;
  84.     short            newWidth;
  85.     short            newHeight;
  86.     
  87.      sizeRect = (**(GetGrayRgn ())).rgnBBox;
  88.     maxWidth  = (sizeRect.right  - sizeRect.left);
  89.     maxHeight = (sizeRect.bottom - sizeRect.top) - MBarHeight;
  90.  
  91.     SetRect (&sizeRect, minWidth, minHeight, maxint, maxint);
  92.     newSize = GrowWindow (whichWindow, curEvent.where, &sizeRect);
  93.     if (newSize != 0) {
  94.         InvalGrowBox (whichWindow);    /* old position */
  95.         newWidth  = LoWord (newSize);
  96.         newHeight = HiWord (newSize);
  97.         SizeWindow (whichWindow, newWidth, newHeight, true);
  98.         ResizeContent ();
  99.         ResizeScrollBars ();
  100.         InvalGrowBox (whichWindow);    /* new position */
  101.     }
  102. } /*DoGrow*/
  103.  
  104. /*----------*/
  105. void DoGoAway    (whichWindow)
  106. WindowPtr        whichWindow;
  107. {
  108.     if (TrackGoAway (whichWindow, curEvent.where)) {
  109.         DoClose ();
  110.     }
  111. } /*DoGoAway*/
  112.  
  113. /*----------*/
  114. void DoZoom        (whichWindow, inOrOut)
  115. WindowPtr        whichWindow;
  116. short            inOrOut;
  117. {
  118.     if (TrackBox (whichWindow, curEvent.where, inOrOut)) {
  119.         EraseRect  (&whichWindow->portRect);
  120.         ZoomWindow (whichWindow, inOrOut, false);
  121.         InvalRect  (&whichWindow->portRect);
  122.         ResizeContent ();
  123.         ResizeScrollBars ();
  124.     }
  125. } /*DoZoom*/
  126.